import { ref, onUnmounted, onMounted } from 'vue'

interface position {
    x: any
    y: any
}

export function useMouse(): position {
    const x = ref(0)
    const y = ref(0)
    const update = (e: MouseEvent) => {
        y.value = e.pageY
        x.value = e.pageX
    }
    onMounted(() => {
        window.addEventListener('mousemove', update)
    })
    onUnmounted(() => {
        window.removeEventListener('mousemove', update)
    })
    return {
        x,
        y,
    }
}
